<!DOCTYPE html>
<html lang="en">
<head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Document</title>
</head>
<body>
  <script>
  window.onload=function(){
    function myC(idStr,fun){
var btn=document.getElementById(idStr);
btn.onclick=fun;
    }
    myC('btn',function(){
var li=document.createElement('li');
var t=document.createTextNode("广州");
var city=document.getElementById('city');
city.appendChild(li);
    }
  ) ;
  myC('btn1',function(){
    var li=document.createElement('li');
    var t=document.createTextNode("广州");
    li.appendChild(t);
    var bj=document.getElementById('bj');
    var city=document.getElementById('city');
    city.insertBefore(li,bj);
  } );
  myC('btn0',function(){
    var li=document.createElement('li');
    var t=document.createTextNode("广州");
    li.appendChild(t);
    var bj=document.getElementById('bj');
    var city=document.getElementById('city');
    city.replaceChild(li,bj);
  });
  myC('btn2',function(){
    var bj=document.getElementById('bj');
    var city=document.getElementById('city');
    city.removeChild(bj);//bj.parentNode.removeChild(bj);
  });
  myC('btn3',function(){
    var bj=document.getElementById('bj');
    bj.innerHTML="新余";
  });
  myC('btn4',function(){
    var city=document.getElementById('city');
    city.innerHTML+="<li>广州</li>"
  })
  }
</script>
<body>
<ul id="city">
  <li id="bj">北京</li>
  <li>上海</li>
  <li>东京</li>
  <li>首尔</li>
</ul>
<div id="idStr">
<button type="button" id="btn" value="添加" >点击</button>
<button id="btn1">插入</button>
<button id="btn2">删除</button>
<button id="btn0">替换</button>
<button id="btn3">修改</button>
<button id="btn4">添加</button>
</div>
</body>
</html>